<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户组添加用户</title>
<link rel="stylesheet" type="text/css" href="$request.getContextPath()/resources/layui/css/layui.css">
<link rel="shortcut icon" type="image/x-icon" href="$request.getContextPath()/resources/cws/images/logo.ico" media="screen" />
</head>
<body>
<form class="layui-form" action="">
  <input type="hidden" name="groupId" value="$!groupId">
  <div class="layui-form-item">
    <label class="layui-form-label">选择用户</label>
    <div class="layui-input-inline">
      <select name="userId" required lay-verify="required">
        <option value="0">请选择</option>
        #foreach($user in $users)
        <option value="$user.userId">$user.userName</option>
        #end
      </select>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">用户权限</label>
    <div class="layui-input-inline">
      <input type="radio" name="privilage" value="1" title="员工" checked>
      <input type="radio" name="privilage" value="2" title="副组长" >
      <input type="radio" name="privilage" value="3" title="组长">
    </div>
  </div>
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">用户描述</label>
    <div class="layui-input-block">
      <textarea id="groupDesc" name="remark" placeholder="请输入用户组描述" class="layui-textarea"></textarea>
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block submit-btn">
      <button class="layui-btn" lay-submit lay-filter="addGroupUserForm">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
</body>
<script type="text/javascript" src="$request.getContextPath()/resources/jquery/jquery-3.1.0.min.js"></script>
<script type="text/javascript" src="$request.getContextPath()/resources/layui/layui.js"></script>
<script type="text/javascript" src="$request.getContextPath()/resources/layui/lay/modules/element.js"></script>
<script type="text/javascript">
$(function(){
	layui.use(['form', 'layedit', 'laydate'], function(){
		var form = layui.form(),layer = layui.layer,layedit = layui.layedit,laydate = layui.laydate;
		//监听提交
		form.on('submit(addGroupUserForm)', function(data){
			if(data.field.userId==0){
				layer.alert("请选择一个用户");
			}else{
				$.post("$request.getContextPath()/system/group/memberAdd",data.field,function(data){
					if(data.code==200){
						var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
						parent.layer.close(index); //再执行关闭   
					}else{
						layer.alert(data.msg);
					}
				});	
			}
		    return false;
		});
	});
});
</script>
</html>